Part 13.1 - Machine Learning Python Programming Concepts

Agenda

Honey, do you know about Machine Learning?

image.png

Many peopole around us expects us to know about Machine Learning. Why?

Big Picture of Data Science, AI, Machine Learrning, Deep Learning

image-2.png

## Left aligned image

Current AI Implementation

Voice Regnition

image.png

Recommendation - Amazon, Netflix, Spotify

image.png

Chatbot (Online Customer Service)

image.png

AI Assistant (AI System for accomplishing Real-World Tasks over the phone)

image.png

Amazon Go (Casher less Grocery Store)

image.png

AlphaGO – Beat “Go” World Champion

image.png

image.png

AI Market Expected Growth

The global AI market is expected to grow from 40 billion in 2020 to 51 billion in 2021 at a compound annual growth rate (CAGR) of 28.4%. The market is expected to reach 171 billion in 2025 at a CAGR of 35%.

Machine Learning Introduction

An application of artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed. image.png

What is it?

image.png

How does human learn?

How does Machine learn?

image-2.png

Machine Learning Functions

Hypothesis function

Cost function (loss function)

Gradient Descent (optimizer)

How Machine Learning works

Hypothesis function vs cost function vs gradient descent

image-2.png

Teaching Young Childrens about Cat Pictures

image.png

  1. Show first sets of pictures
  2. Tell kids that some are “cat” pictures and some are NOT.
  3. Explain why some are NOT “cat” pictures
  4. Show next sets of pictures
  5. Repeat 2-3
  6. Keep showing CAT pictures using step 4 and 5 until kids understand “cat” pictures.

Machine Learning Process

  1. Select Data and hypothesis function
  2. Start with random parameters of hypothesis function
  3. Process first sets of data through hypothesis function
  4. Find predicted values from hypothesis function
  5. Calculate cost function ( actual – predicted)
  6. Minimize cost function using Gradient Descent
  7. Update parameters of hypothesis function based on cost function minimization
  8. Repeat steps ( 3 and 7) with next sets of data until the cost function become 0 or at the lowest point.

1. Select Data and Hypothesis Function

Data :

Hypothesis function:

image-2.png

2. Start with random parameters of hypothesis function

hθ(x) = 4x at θ = 4

3 & 4 Process first set of data in hypothesis function and predict values from hypothesis function

hθ(x) = 4x at θ = 4

x = [1,2,3]

5. Calculate cost function : difference between actual and predicted

Cost function : J(θ)=(1/2m)*sum[(Y - h)^2]

J(4) =(1/6)*sum((2-4)^2 + (4-8)^2 + (6-12)^2) = 56/6 = 9.333

image-2.png

Cost Function in different Parameter

Optimum θ is 2 : Best fitted model is H = 2X.

image-2.png

Gradient Descent

6. Minimize cost function using Gradient Descent

image-2.png

Learning Rate ( alpha)

At θ:= θ – alpha* d/dθJ(θ) at θ =4 assuming d/dθJ(4) = 2.

If the learning rate (alpha) = 0.1,
θ:= 4 - 0.1 2 = 3.8
If the learning rate (alpha) = 0.5
θ:= 4 – 0.5
2 = 3

7. Update parameters of hypothesis function based on cost function

8.Repeat steps ( 3 and 7) with next sets of data

At second iteration,

And the iteration will go on until the cost function gest to 0 like J(θ)=0 or it no longer decreases or no more data.

The cost function decreases and slope (θ) decreases as well to the optimum point.

Machine Learning Interview

Interviewer: What’s your biggest strength ?
Me: I’m an expert in Machine Learning.
Interviewer: What’s 9 + 10 ?
Me: It is 3.
Interviewer: Not even close. It’s 19.
Me: It’s 16.
Interviewer: Wrong. It's still 19.
Me: It’s 18.
Interviewer: No, it’s 19… Arghhh
Me: It’s 19.
Interviewer: You are hired.